<include file="../header" />
<body class="J_scroll_fixed">
<script type="text/javascript">
    function endWorkorder() {
        if (!confirm("确认要交付工单吗？")) {
            return false;
        }
    }

</script>
<form class="well form-search" method="post" style="float:left" action="{:U('Workorder/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：{:getEnumSelectWidget($statusEnum, "wo#status", $status, 1)}
            &nbsp;用户名称：<input type="text" name="cus#nickname-like" value="{$nickname}" />
            产品名称：<input type="text" name="p#product_name-like" value="{$product_name}" />
            <br>
            类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：{:getEnumSelectWidget($typeEnum, "wo#workorder_type", $type, 1)}下单开始时间：<input type="text" value="{$begin_time}" class="date J_date" name="wo#create_time-egt" />
            下单截止时间：<input type="text" value="{$end_time}" class="date J_date" name="wo#create_time-elt" />
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn" href="{:U('Workorder/index')}">重置</a>
        </span>
        </div>
    </div>
</form>
<div class="wrap J_check_wrap">
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th>工单信息</th>
            <th>患者信息</th>
            <th>下单信息</th>
            <th>接单信息</th>
            <th>交付时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="workorderList" item="vo">
            <tr>
                <php>
                    if($vo["workorder_type"] == 1){
                        $type = "AFO";
                    }
                    if($vo["workorder_type"] == 2){
                        $type = "脊柱";
                    }
                    if($vo["workorder_type"] == 3){
                    $type = "物理检查表";
                    }
                </php>
                <td>{$vo.workorder_id}（{$type} {$vo.side}）<br>{$vo.workorder_no}</td>
                <td>{$vo.nickname}姓名：{$vo.patient_name}，性别：{$vo.sex}，年龄：{$vo.age}<br>诊断：{$vo.diagnosis}</td>
                <td>下单人：{$vo.creator} {$vo.update_time}
                    <br>
                    <if condition="$vo['workorder_type'] neq '3'">
                    销售：{$vo.sales}
                    </if>
                    <br>
                    处方人：{$vo.prescriber} {$vo.prescribe_time}
                </td>
                <if condition="$vo['status'] gt $statusEnum['DISTPATCHED'] && $vo['workorder_type'] neq '3'">
                    <td>检测人：{$vo.examinator} {$vo.exam_time} <br>矫形器类型：{$vo.type_name}，价格：{$vo.price}，预付款：{$vo.deposit}，预计交付：{$vo.delivery_date}</td>
                <else/>
                    <td></td>
                </if>
                <if condition="$vo['status'] gt $statusEnum['PROCESSING']">
                    <td>{$vo.end_time}</td>
                <else/>
                    <td></td>
                </if>
                <td>{:getEnumString($statusEnum, $vo['status'])}</td>
                <td>
                    <if condition="$vo['status'] egt $statusEnum['WAITING_DISTPATCH']">
                        <!--a class="btn btn-success" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>接单</a>
                    <else/-->
                        <a class="btn btn-info" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>查看与打印</a>
                    </if>
                    <php>
                        $prescriber = 0;
                        $employee_idArr = explode(',', $user['employee_id']);
                        foreach ($employee_idArr as $value) {
                            if($value == $vo['prescriber_id'] && $vo['status'] == '1'){
                                $prescriber = 1;
                            }
                        }
                    </php>
                    <if condition="$prescriber eq 1">
                        <a class="btn btn-danger" href='{:U("workorder/rx",array("id"=>$vo["workorder_id"]))}'>处方</a>
                    </if>
                    <!--if condition="$vo['workorder_type'] eq '1'">
                        <a class="btn btn-success" href='{:U("workorder/record",array("id"=>$vo["workorder_id"]))}'>生产批记录</a>
                    </if>
                        <!--if condition="$vo['status'] eq $statusEnum['PROCESSING']">
                        <a class="btn btn-success" onclick="if(confirm('确认要交付工单?')==false)return false;" href='{:U("workorder/endworkorder",array("id"=>$vo["workorder_id"]))}' >交付工单</a>
                    </if-->
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>